package kr.hyunist.androidcomplete01saeildamil.ch12;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.*;

public class ScrollViewEx extends Activity {
	int[] mImageArr = { R.drawable.bigman, R.drawable.triangle,
			R.drawable.una_street, R.drawable.golden_cross,
			R.drawable.gaguachunsun, R.drawable.powi, R.drawable.doctor_order };
	
	int[] mBigArr = { R.drawable.bigman_big, R.drawable.triangle_big,
			R.drawable.una_street_big, R.drawable.golden_cross_big,
			R.drawable.gaguachunsun_big, R.drawable.powi_big, R.drawable.doctor_order_big };

	Button[] imageBtn;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.scrollviewex);
		
		LinearLayout layout = (LinearLayout) findViewById(R.id.scrollviewlinear);
		imageBtn = new Button[mBigArr.length];
		for(int i = 0; i < mBigArr.length; i++){
			imageBtn[i] = new Button(this);
			imageBtn[i].setBackgroundResource(mImageArr[i]);
			layout.addView(imageBtn[i]);
			imageBtn[i].setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {

					for(int i = 0; i < mImageArr.length; i++){
						if(v == imageBtn[i]){
							ImageView bigImage = (ImageView) findViewById(R.id.scrollviewbig_image);
							bigImage.setImageResource(mBigArr[i]);
							break;
						}
					}
					
				}
				
			});
		}
	
		
	}
	

}

